#include<iostream>
#include<stack>
#include<string.h>
using namespace std;

int main()
{
    stack<char> c;
    char a[5000];
    gets(a);
    int l=0,r=0;
    int stra=strlen(a);
    for(int i=0;i<stra;i++){
        if(a[i]=='{'||a[i]=='['||a[i]=='('){
            l++;
            c.push(a[i]);
        }else if(c.top()=='('&&a[i]==')'){
            c.pop();
            r++;
        }else if(c.top()=='['&&a[i]==']'){
            c.pop();
            r++;
        }else if(c.top()=='('&&a[i]==')'){
            c.pop();
            r++;
        }else{
            r++;
        }
    }
    // cout<<l<<" "<<r<<" "<<endl;
    if(r>l){
        cout<<"Extra right brackets";
    }else if(l>r){
        cout<<"Extra left brackets";
    }else if(!c.empty()){
        cout<<"Brackets not match";
    }else{
        cout<<"Brackets match";
    }
}
